const { resolve } = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './index.js',
  output: {
    filename: '[name].js',
    path: resolve(__dirname, 'dist')
  },
  devServer: {
    contentBase: resolve(__dirname, 'dist'),
    compress: true,
    port: 3000
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './index.html'
    })
  ],
  resolve: {
    alias: {
      'vue': 'vue/dist/vue.esm-bundler.js'
    }
  },
  optimization: {
    splitChunks: {
      chunks: 'all',
      cacheGroups: {
        vendors: {
          name: 'chunk-vendor',
          test: /[\\/]node_modules[\\/]/,
          priority: -10
        },
        elementUI: {
          name: 'chunk-elementUI',
          test: /[\\/]node_modules[\\/]_?element3(.*)/,
          priority: 20
        }
      }
    }
  },
  mode: 'development'
}